package string.nowcoder.medium;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author bruin_du
 * @description 参数解析
 * https://www.nowcoder.com/practice/668603dc307e4ef4bb07bcd0615ea677?
 * tpId=37&&tqId=21297&rp=1&ru=/activity/oj&qru=/ta/huawei/question-ranking
 * @date 2022/5/9 17:26
 **/
public class ParameterAnalyse {
    //下次可以尝试不用顺序表保存结果，先遍历一遍有多少字符串
    //后边用标志位判断空格是否在双引号里面,在进行区别打印
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            String str = in.nextLine();
            int length = str.length() - 1;
            List<String> list = new ArrayList<>();
            int i = 0;
            while(i <= length){
                StringBuilder sb = new StringBuilder();
                char ch = str.charAt(i);
                if(ch == '"'){
                    while(i < length){
                        char tmp = str.charAt(++i);
                        if(tmp != '"'){
                            sb.append(tmp);
                        }else
                            break;
                    }
                    if(i + 1 < length)
                        i ++;
                }else{
                    sb.append(ch);
                    while(i < length){
                        char tmp = str.charAt(++i);
                        if(tmp != ' '){
                            sb.append(tmp);
                        }else
                            break;
                    }
                }
                //这里的i++不能放在if条件判断里，否则会造成死循环的
                i++;
                list.add(sb.toString());
            }
            System.out.println(list.size());
            for(int j = 0; j < list.size(); j++){
                System.out.println(list.get(j));
            }
        }
    }
}
